package cn.edu.hbwe.book.servlet.Notice;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.hbwe.book.dao.NoticeDao;
import cn.edu.hbwe.book.dao.impl.BookDaoImpl;
import cn.edu.hbwe.book.entity.Notice;

/**
 * 
 *	后台根据id查询公告的servlet
 */
@WebServlet("/FindByIdNoticeServlet")
public class FindByIdNoticeServlet extends HttpServlet{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		this.doPost(request, response);
	}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	// TODO Auto-generated method stub
	response.setContentType("text/html;charset=utf-8");
	request.setCharacterEncoding("utf-8");
	String id = request.getParameter("id");
	try {
		Notice notice=NoticeDao.findNotice(id);
		NoticeDao.findNotice(id);
		request.setAttribute("n", notice);
		request.getRequestDispatcher("/admin/notices/edit.jsp").forward(request, response);
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}}